﻿using LeSoft.Application.Bussiness;
using LeSoft.Application.Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LeSoft.Application.Web.Areas.SystemManage.Controllers
{
    public class DataBaseTableController : MvcControllerBase
    {
        private DataBaseTableBLL dataBaseTableBLL = new DataBaseTableBLL();
        #region 视图
        [HttpGet]
        [HandlerAuthorize(PermissionMode.Enforce)]
        public ActionResult Index()
        {
            return View();
        }
      #endregion

        #region 获取数据
        /// <summary>
        /// 数据库表字段列表
        /// </summary>
        /// <param name="dataBaseLinkId">库连接Id</param>
        /// <param name="tableName">表明</param>
        /// <returns>返回列表Json</returns>
        [HttpGet]
        public ActionResult GetTableFiledListJson(string dataBaseLinkId, string tableName)
        {
            var data = dataBaseTableBLL.GetTableFiledList(dataBaseLinkId, tableName);
            return ToJsonResult(data);
        }
        /// <summary>
        /// 数据库表列表
        /// </summary>
        /// <param name="dataBaseLinkId">库连接Id</param>
        /// <param name="keyword">关键字查询</param>
        /// <returns>返回列表Json</returns>
        [HttpGet]
        public ActionResult GetTableListJson(string dataBaseLinkId, string keyword)
        {
            var data = dataBaseTableBLL.GetTableList(dataBaseLinkId, keyword);
            return ToJsonResult(data);
        }
        #endregion
    }
}
